<?php

/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2023/9/26 10:09
 * Desc: 会员折扣
 */
class Service_Api_Member_Discount extends Contract_Api_Member_Discount
{

    public function get_discount($mid, $params): array
    {
        /**
         * @var $type_id
         * @var $product_id
         */
        extract($params);

        $rank    = Model_Member::member_rank($mid, array('return' => 'all'));
        if(!$rank['member_discount']){
            //验证当前等级是否支持会员折扣  不支持直接为0
            return [];
        }
        $rank_id = intval($rank['current_rank']['id']);

        //线路,户外处理
        if ($type_id == 1) {
            $data = Model_Api_V2_Discount::line_discount($rank_id, $type_id, $product_id);
        } elseif ($type_id == 114) {
            $data = Model_Api_V2_Discount::outdoor_discount($rank_id, $type_id, $product_id);
        } else {
            $data = Model_Api_V2_Discount::normal_discount($rank_id, $type_id, $product_id);
        }

        return $data;
    }
}